<?php
class Controller  {
	
	public $type = 'GtkWindow';
	public $widgets = array();
	public $title = 'Default';
	public $width = 500;
	public $height = 500;
	public $xPosition = 200;
	public $yPosition = 200;
	public $connectSimpleActions = array('clicked');
	
	final function __construct() {
		$this->View = new View($this);
		$this->bla = 'blubb';
		pr($this->View->controller->bla);
	}	
	
	public function main() {}
	
	public function render() {
		$gtk = new $this->type;
		$gtk->set_title($this->title);
		$gtk->set_default_size($this->width, $this->height);
		$gtk->move($this->xPosition, $this->yPosition);	
		
		foreach($this->widgets as $widget) {
			if(is_a($widget, 'GtkWidget')) {
				$gtk->add($widget);				
			} else {
				pr('Widget not found');
			}
		}

		$gtk->connect_simple('destroy', array($this, 'quit'));
		$gtk->show_all();
		Gtk::main();
	}
	
	function quit() {
		Gtk::main_quit();
	}
	
	/**
	 * Callbacks
	 */
	function beforeStart() {}
	function afterStart() {}
	function beforeRender() {}
	function end() {}
}
?>